#include "Vector2D.h"
#include "math.h"

CVector2D::CVector2D(void):x(0),y(0){}
CVector2D::CVector2D(float x, float y):x(x),y(y)
{}

CVector2D::~CVector2D(void){}

void CVector2D::setX(float x)
{
	this->x=x;
}
void CVector2D::setY(float y)
{
	this->y=y;
}

float CVector2D::getX(void)const
{
	return this->x;
}
float CVector2D::getY(void)const
{
	return this->y;
}

CVector2D CVector2D::operator+(const CVector2D& v)
{
	CVector2D result(this->x+v.x,this->y+v.y);
	return result;
}
CVector2D CVector2D::operator*(const float f)
{
	CVector2D result(this->x*f,this->y*f);
	return result;
}
CVector2D CVector2D::operator-(const CVector2D& v)
{
	CVector2D result(this->x-v.x,this->y-v.y);
	return result;
}

float CVector2D::norme(void)const
{
	return sqrt(x*x+y*y);
}

void CVector2D::normalise(void)
{
	float norme= this->norme();
	x=x/norme;
	y=y/norme;
}
